package cn.pzaily.orange.manage.controller;

import cn.pzaily.orange.core.utils.page.PageRequest;
import cn.pzaily.orange.core.utils.page.PageResponse;
import cn.pzaily.orange.core.utils.http.ResponseResult;
import cn.pzaily.orange.manage.model.SysDict;
import cn.pzaily.orange.manage.service.SysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @PackageName: cn.pzaily.orange.manage.controller
 * @Description:
 * @Author: Pang
 * @Date: 2021-05-11 22:08
 */
@RestController
@RequestMapping(value = "/dict")
public class SysDictController {

    @Autowired
    private SysDictService dictService;


    @PreAuthorize("hasAuthority('sys:dice:save')")
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public ResponseResult save(@RequestBody SysDict dict) {
        return ResponseResult.okResult(dictService.save(dict));
    }


    @PreAuthorize("hasAuthority('sys:dice:list')")
    @RequestMapping(value = "/findPage", method = RequestMethod.POST)
    public ResponseResult findPage(@RequestBody PageRequest request) {
        PageResponse page = dictService.findPage(request);
        return ResponseResult.okResult(page);
    }

}
